package com.application.lucky.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.application.lucky.R;
import com.application.lucky.bean.jsonBean.BaoBiaoBean;
import com.application.lucky.request.CallBackEx;
import com.application.lucky.request.RedPRequest;
import com.application.lucky.widget.TitlebarView;
import com.application.lucky.widget.popupwindow.BaoBiaoTimePop;
import com.application.mylibrary.base.BaseActivity;
import com.baselib.libnetwork.net.libnetworkcomponent.BaseResponse;
import com.qunar.im.ui.util.MoneyUtils;

import java.text.DecimalFormat;
import java.util.Date;

public class MyBaoBiaoActivity extends BaseActivity {

    private TextView mTxtChongzhi;
    private View mView1;
    private ImageView mImg1;
    private TextView mTxtChongzhijine;
    private ImageView mImg2;
    private TextView mTxtTixianjine;
    private TextView mTxtSaolei;
    private RelativeLayout mRl1;
    private TextView mTxtSaoleiValue;
    private ImageView mImg3;
    private View mView2;
    private TextView mTxtFabaozonge;
    private TextView mTxtFabao;
    private TextView mTxtQiangbaozonge;
    private TextView mTxtQiangbao;
    private View mView3;
    private TextView mTxtFabaogeshuValue;
    private TextView mTxtFabaogeshu;
    private TextView mTxtQiangbaogeshuValue;
    private TextView mTxtQiangbaogeshu;
    private View mView4;
    private TextView mTxtZhongleicishuValue;
    private TextView mTxtZhongleicishu;
    private TextView mTxtPeifujineValue;
    private TextView mTxtPeifujine;
    private View mView5;
    private TextView mTxtShougeValue;
    private TextView mTxtShougejie;
    private TextView mTxtTuikuanjineValue;
    private TextView mTxtTuikuanjine;
    private TextView mTxtJinqiangbaobiao;
    private RelativeLayout mRl2;
    private TextView mTxtJinqiangZongyingkuiValue;
    private ImageView mImg4;
    private View mView6;
    private TextView mTxtJinqiangFabaozongeValue;
    private TextView mTxtJinqiangFabao;
    private TextView mTxtJinqiangFabaogehsuValue;
    private TextView mTxtJinqiangFabaogeshu;
    private View mView7;
    private TextView mTxtJinqiangShougejineValue;
    private TextView mTxtJinqiangShougejine;
    private TextView mTxtJinqiangZhongleicishuValue;
    private TextView mTxtJinqiangZhongleicishu;
    private TextView mTxtDailibaobiao;
    private RelativeLayout mRl3;
    private TextView mTxtDailibaobiaoValue;
    private View mView8;
    private TextView mTxtZhituiliushuiValue;
    private TextView mTxtZhituiliushui;
    private TextView mTxtZhituiwanjiarenshuValue;
    private TextView mTxtZhituiwanjiarenshu;
    private TextView mTxtZhuanzhangbaobiao;
    private View mView9;
    private TextView mTxtZhuanzhangZhuangzhangzongeValue;
    private TextView mTxtZhuanzhangZhuangzhangzonge;
    private TextView mTxtZhuanzhangShoukuanzongeValue;
    private TextView mTxtZhuanzhangShoukuanzonge;
    private View mView10;
    private TextView mTxtZhuanzhangShouxufeiValue;
    private TextView mTxtZhuanzhangShouxufei;
    private TextView mTxtHongbaobaobiao1;
    private View mView11;
    private TextView mTxtHongbaobaobiaoFabaojineValue;
    private TextView mTxtJine;
    private TextView mTxtHongbaobaobiaoQiangbaijineValue;
    private TextView mTxtHongbaobaobiaoQiangbaojine;
    private View mView12;
    private TextView mTxtHongbaobaobiaoFabaogeshuValue;
    private TextView mTxtHongbaobaobiaoFabaogeshu;
    private TextView mTxtHongbaobaobiaoQiangbaogehsuValue;
    private TextView mTxtHongbaobaobiaoQiangbaogeshu;
    private View mView13;
    private TextView mTxtHongbaobaobiaoTuikuanjineValue;
    private TextView mTxtHongbaobaobiaoTuikuanjie;
    private TextView mTxtHongbaobaobiao2;
    private View mView14;
    private TextView mTxtHongbaobaobiaoZhituiValue;
    private TextView mTxtHongbaobaobiaoZhitui;
    private TextView mTxtHongbaobaobiaoBaozishunziValue;
    private TextView mTxtHongbaobaobiaoShunzibaozi;
    private View mView15;
    private TextView mTxtHongbaobaobaioFabaomaneValue;
    private TextView mTxtHongbaobaobiaoFabaomane;
    private TextView mTxtHongbaobaobiaoShouchongValue;
    private TextView mTxtHongbaobaobiaoShouchong;
    private View mView16;
    private TextView mTxtHongbaobaobiaoYaohaoyouValue;
    private TextView mTxtHongbaobaobiaoYaohaoyou;
    private TextView mTxtHongbaobaobiaoZhuceValue;
    private TextView mTxtHongbaobaobiaoZhuce;
    private View mView17;
    private TextView mTxtHongbaobaobiaoJiuyuanValue;
    private TextView mTxtHongbaobaobiaoJiuyuan;
    private TextView mTxtHongbaobaobiaoChongzhiValue;
    private TextView mTxtHongbaobaobiaoChongzhi;
    private TextView mTxtBenchibaoma;
    private View mView18;
    private TextView mTxtBenchiLiushuiValue;
    private TextView mTxtBenchiLiushui;
    private TextView mTxtBenchiShuyingValue;
    private TextView mTxtBenchiShuying;
    private TextView mTxtHuanlejinhua;
    private View mView19;
    private TextView mTxtJinhuaLiushuiValue;
    private TextView mTxtJinhuaLiushui;
    private TextView mTxtJinhuaShuyingValue;
    private TextView mTxtJinhuaShuying;
    private TextView mTxtLonghudou;
    private View mView20;
    private TextView mTxtLonghudouLiushuiValue;
    private TextView mTxtLonghudouLiushui;
    private TextView mTxtLonghudouShuyingValue;
    private TextView mTxtXingyunzhuanpan;
    private View mView21;
    private TextView mTxtXingyunzhuanpanLiushuiValue;
    private TextView mTxtXingyuanzhuanpanLiushui;
    private TextView mTxtXinyunzhuanpanShuyingValue;
    private TextView mTxtShuiguoji;
    private View mView22;
    private TextView mTxtShuiguojiLiushuiValue;
    private TextView mTxtShuiguojiShuyingValue;
    private TitlebarView titleBat;
    private BaoBiaoTimePop baoBiaoTimePop;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
        loadData(1, new Date().getTime());
    }

    private void loadData(long time, long endTime) {
        new RedPRequest().red_accounts_overview(time, endTime, new CallBackEx<BaseResponse<BaoBiaoBean>>() {
            @Override
            public void onFailed(int code) {

            }

            @Override
            public void onSuccess(BaseResponse<BaoBiaoBean> stringBaseResponse) {
                BaoBiaoBean dataInfo = stringBaseResponse.dataInfo;
                if (dataInfo != null) {
                    double recharge = dataInfo.getRecharge();//充值金额
                    mTxtChongzhijine.setText(doubleToString(recharge));
                    double extract = dataInfo.getExtract();
                    mTxtTixianjine.setText(doubleToString(extract));
                    double robMoney = dataInfo.getRobMoney();//抢包金额
                    mTxtQiangbaozonge.setText(doubleToString(robMoney));
                    int robCount = dataInfo.getRobCount();//抢包个数
                    mTxtQiangbaogeshuValue.setText(robCount + "");
                    int redCount = dataInfo.getRedCount();//发包个数
                    mTxtFabaogeshuValue.setText(redCount + "");
                    double redMoney = dataInfo.getRedMoney();//发包金额
                    mTxtFabaozonge.setText(doubleToString(redMoney));
                    int mediumNum = dataInfo.getMediumNum();//中雷次数
                    mTxtZhongleicishuValue.setText(mediumNum + "");
                    double loss = dataInfo.getLoss();//赔付金额
                    mTxtPeifujineValue.setText(doubleToString(loss));
                    double earn = dataInfo.getEarn();//收割金额
                    mTxtShougeValue.setText(doubleToString(earn));
                    double back = dataInfo.getBack();
                    mTxtTuikuanjineValue.setText(doubleToString(back));
                }
            }
        });
    }

    public String doubleToString(double num) {
        //使用0.00不足位补0，#.##仅保留有效位

        return "¥ " + new DecimalFormat("0.00").format(Double.valueOf(MoneyUtils.getMoney(num)));
    }

    @Override
    public void beforeInit() {

    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_my_baobiao;
    }

    private void initView() {
        titleBat = findViewById(R.id.title_bar);
        titleBat.setOnViewClick(new TitlebarView.onViewClick() {
            @Override
            public void leftClick() {
                finishAnim();
            }

            @Override
            public void rightClick() {
                if (baoBiaoTimePop == null) {
                    baoBiaoTimePop = new BaoBiaoTimePop(MyBaoBiaoActivity.this, new BaoBiaoTimePop.TimeSelectListener() {
                        @Override
                        public void selectTime(long time, long endTime) {
                            loadData(time, endTime);
                        }
                    });
                }
                baoBiaoTimePop.show(titleBat);

            }
        });
        mTxtChongzhi = (TextView) findViewById(R.id.txt_chongzhi);
        mView1 = (View) findViewById(R.id.view1);
        mImg1 = (ImageView) findViewById(R.id.img1);
        mTxtChongzhijine = (TextView) findViewById(R.id.txt_chongzhijine);
        mImg2 = (ImageView) findViewById(R.id.img2);
        mTxtTixianjine = (TextView) findViewById(R.id.txt_tixianjine);
        mTxtSaolei = (TextView) findViewById(R.id.txt_saolei);
        mRl1 = (RelativeLayout) findViewById(R.id.rl1);
        mTxtSaoleiValue = (TextView) findViewById(R.id.txt_saolei_value);
        mImg3 = (ImageView) findViewById(R.id.img3);
        mView2 = (View) findViewById(R.id.view2);
        mTxtFabaozonge = (TextView) findViewById(R.id.txt_fabaozonge);
        mTxtFabao = (TextView) findViewById(R.id.txt_fabao);
        mTxtQiangbaozonge = (TextView) findViewById(R.id.txt_qiangbaozonge);
        mTxtQiangbao = (TextView) findViewById(R.id.txt_qiangbao);
        mView3 = (View) findViewById(R.id.view3);
        mTxtFabaogeshuValue = (TextView) findViewById(R.id.txt_fabaogeshu_value);
        mTxtFabaogeshu = (TextView) findViewById(R.id.txt_fabaogeshu);
        mTxtQiangbaogeshuValue = (TextView) findViewById(R.id.txt_qiangbaogeshu_value);
        mTxtQiangbaogeshu = (TextView) findViewById(R.id.txt_qiangbaogeshu);
        mView4 = (View) findViewById(R.id.view4);
        mTxtZhongleicishuValue = (TextView) findViewById(R.id.txt_zhongleicishu_value);
        mTxtZhongleicishu = (TextView) findViewById(R.id.txt_zhongleicishu);
        mTxtPeifujineValue = (TextView) findViewById(R.id.txt_peifujine_value);
        mTxtPeifujine = (TextView) findViewById(R.id.txt_peifujine);
        mView5 = (View) findViewById(R.id.view5);
        mTxtShougeValue = (TextView) findViewById(R.id.txt_shouge_value);
        mTxtShougejie = (TextView) findViewById(R.id.txt_shougejie);
        mTxtTuikuanjineValue = (TextView) findViewById(R.id.txt_tuikuanjine_value);
        mTxtTuikuanjine = (TextView) findViewById(R.id.txt_tuikuanjine);
        mTxtJinqiangbaobiao = (TextView) findViewById(R.id.txt_jinqiangbaobiao);
        mRl2 = (RelativeLayout) findViewById(R.id.rl2);
        mTxtJinqiangZongyingkuiValue = (TextView) findViewById(R.id.txt_jinqiang_zongyingkui_value);
        mImg4 = (ImageView) findViewById(R.id.img4);
        mView6 = (View) findViewById(R.id.view6);
        mTxtJinqiangFabaozongeValue = (TextView) findViewById(R.id.txt_jinqiang_fabaozonge_value);
        mTxtJinqiangFabao = (TextView) findViewById(R.id.txt_jinqiang_fabao);
        mTxtJinqiangFabaogehsuValue = (TextView) findViewById(R.id.txt_jinqiang_fabaogehsu_value);
        mTxtJinqiangFabaogeshu = (TextView) findViewById(R.id.txt_jinqiang_fabaogeshu);
        mView7 = (View) findViewById(R.id.view7);
        mTxtJinqiangShougejineValue = (TextView) findViewById(R.id.txt_jinqiang_shougejine_value);
        mTxtJinqiangShougejine = (TextView) findViewById(R.id.txt_jinqiang_shougejine);
        mTxtJinqiangZhongleicishuValue = (TextView) findViewById(R.id.txt_jinqiang_zhongleicishu_value);
        mTxtJinqiangZhongleicishu = (TextView) findViewById(R.id.txt_jinqiang_zhongleicishu);
        mTxtDailibaobiao = (TextView) findViewById(R.id.txt_dailibaobiao);
        mRl3 = (RelativeLayout) findViewById(R.id.rl3);
        mTxtDailibaobiaoValue = (TextView) findViewById(R.id.txt_dailibaobiao_value);
        mView8 = (View) findViewById(R.id.view8);
        mTxtZhituiliushuiValue = (TextView) findViewById(R.id.txt_zhituiliushui_value);
        mTxtZhituiliushui = (TextView) findViewById(R.id.txt_zhituiliushui);
        mTxtZhituiwanjiarenshuValue = (TextView) findViewById(R.id.txt_zhituiwanjiarenshu_value);
        mTxtZhituiwanjiarenshu = (TextView) findViewById(R.id.txt_zhituiwanjiarenshu);
        mTxtZhuanzhangbaobiao = (TextView) findViewById(R.id.txt_zhuanzhangbaobiao);
        mView9 = (View) findViewById(R.id.view9);
        mTxtZhuanzhangZhuangzhangzongeValue = (TextView) findViewById(R.id.txt_zhuanzhang_zhuangzhangzonge_value);
        mTxtZhuanzhangZhuangzhangzonge = (TextView) findViewById(R.id.txt_zhuanzhang_zhuangzhangzonge);
        mTxtZhuanzhangShoukuanzongeValue = (TextView) findViewById(R.id.txt_zhuanzhang_shoukuanzonge_value);
        mTxtZhuanzhangShoukuanzonge = (TextView) findViewById(R.id.txt_zhuanzhang_shoukuanzonge);
        mView10 = (View) findViewById(R.id.view10);
        mTxtZhuanzhangShouxufeiValue = (TextView) findViewById(R.id.txt_zhuanzhang_shouxufei_value);
        mTxtZhuanzhangShouxufei = (TextView) findViewById(R.id.txt_zhuanzhang_shouxufei);
        mTxtHongbaobaobiao1 = (TextView) findViewById(R.id.txt_hongbaobaobiao1);
        mView11 = (View) findViewById(R.id.view11);
        mTxtHongbaobaobiaoFabaojineValue = (TextView) findViewById(R.id.txt_hongbaobaobiao_fabaojine_value);
        mTxtJine = (TextView) findViewById(R.id.txt_jine);
        mTxtHongbaobaobiaoQiangbaijineValue = (TextView) findViewById(R.id.txt_hongbaobaobiao_qiangbaijine_value);
        mTxtHongbaobaobiaoQiangbaojine = (TextView) findViewById(R.id.txt_hongbaobaobiao_qiangbaojine);
        mView12 = (View) findViewById(R.id.view12);
        mTxtHongbaobaobiaoFabaogeshuValue = (TextView) findViewById(R.id.txt_hongbaobaobiao_fabaogeshu_value);
        mTxtHongbaobaobiaoFabaogeshu = (TextView) findViewById(R.id.txt_hongbaobaobiao_fabaogeshu);
        mTxtHongbaobaobiaoQiangbaogehsuValue = (TextView) findViewById(R.id.txt_hongbaobaobiao_qiangbaogehsu_value);
        mTxtHongbaobaobiaoQiangbaogeshu = (TextView) findViewById(R.id.txt_hongbaobaobiao_qiangbaogeshu);
        mView13 = (View) findViewById(R.id.view13);
        mTxtHongbaobaobiaoTuikuanjineValue = (TextView) findViewById(R.id.txt_hongbaobaobiao_tuikuanjine_value);
        mTxtHongbaobaobiaoTuikuanjie = (TextView) findViewById(R.id.txt_hongbaobaobiao_tuikuanjie);
        mTxtHongbaobaobiao2 = (TextView) findViewById(R.id.txt_hongbaobaobiao2);
        mView14 = (View) findViewById(R.id.view14);
        mTxtHongbaobaobiaoZhituiValue = (TextView) findViewById(R.id.txt_hongbaobaobiao_zhitui_value);
        mTxtHongbaobaobiaoZhitui = (TextView) findViewById(R.id.txt_hongbaobaobiao_zhitui);
        mTxtHongbaobaobiaoBaozishunziValue = (TextView) findViewById(R.id.txt_hongbaobaobiao_baozishunzi_value);
        mTxtHongbaobaobiaoShunzibaozi = (TextView) findViewById(R.id.txt_hongbaobaobiao_shunzibaozi);
        mView15 = (View) findViewById(R.id.view15);
        mTxtHongbaobaobaioFabaomaneValue = (TextView) findViewById(R.id.txt_hongbaobaobaio_fabaomane_value);
        mTxtHongbaobaobiaoFabaomane = (TextView) findViewById(R.id.txt_hongbaobaobiao_fabaomane);
        mTxtHongbaobaobiaoShouchongValue = (TextView) findViewById(R.id.txt_hongbaobaobiao_shouchong_value);
        mTxtHongbaobaobiaoShouchong = (TextView) findViewById(R.id.txt_hongbaobaobiao_shouchong);
        mView16 = (View) findViewById(R.id.view16);
        mTxtHongbaobaobiaoYaohaoyouValue = (TextView) findViewById(R.id.txt_hongbaobaobiao_yaohaoyou_value);
        mTxtHongbaobaobiaoYaohaoyou = (TextView) findViewById(R.id.txt_hongbaobaobiao_yaohaoyou);
        mTxtHongbaobaobiaoZhuceValue = (TextView) findViewById(R.id.txt_hongbaobaobiao_zhuce_value);
        mTxtHongbaobaobiaoZhuce = (TextView) findViewById(R.id.txt_hongbaobaobiao_zhuce);
        mView17 = (View) findViewById(R.id.view17);
        mTxtHongbaobaobiaoJiuyuanValue = (TextView) findViewById(R.id.txt_hongbaobaobiao_jiuyuan_value);
        mTxtHongbaobaobiaoJiuyuan = (TextView) findViewById(R.id.txt_hongbaobaobiao_jiuyuan);
        mTxtHongbaobaobiaoChongzhiValue = (TextView) findViewById(R.id.txt_hongbaobaobiao_chongzhi_value);
        mTxtHongbaobaobiaoChongzhi = (TextView) findViewById(R.id.txt_hongbaobaobiao_chongzhi);
        mTxtBenchibaoma = (TextView) findViewById(R.id.txt_benchibaoma);
        mView18 = (View) findViewById(R.id.view18);
        mTxtBenchiLiushuiValue = (TextView) findViewById(R.id.txt_benchi_liushui_value);
        mTxtBenchiLiushui = (TextView) findViewById(R.id.txt_benchi_liushui);
        mTxtBenchiShuyingValue = (TextView) findViewById(R.id.txt_benchi_shuying_value);
        mTxtBenchiShuying = (TextView) findViewById(R.id.txt_benchi_shuying);
        mTxtHuanlejinhua = (TextView) findViewById(R.id.txt_huanlejinhua);
        mView19 = (View) findViewById(R.id.view19);
        mTxtJinhuaLiushuiValue = (TextView) findViewById(R.id.txt_jinhua_liushui_value);
        mTxtJinhuaLiushui = (TextView) findViewById(R.id.txt_jinhua_liushui);
        mTxtJinhuaShuyingValue = (TextView) findViewById(R.id.txt_jinhua_shuying_value);
        mTxtJinhuaShuying = (TextView) findViewById(R.id.txt_jinhua_shuying);
        mTxtLonghudou = (TextView) findViewById(R.id.txt_longhudou);
        mView20 = (View) findViewById(R.id.view20);
        mTxtLonghudouLiushuiValue = (TextView) findViewById(R.id.txt_longhudou_liushui_value);
        mTxtLonghudouLiushui = (TextView) findViewById(R.id.txt_longhudou_liushui);
        mTxtLonghudouShuyingValue = (TextView) findViewById(R.id.txt_longhudou_shuying_value);
        mTxtXingyunzhuanpan = (TextView) findViewById(R.id.txt_xingyunzhuanpan);
        mView21 = (View) findViewById(R.id.view21);
        mTxtXingyunzhuanpanLiushuiValue = (TextView) findViewById(R.id.txt_xingyunzhuanpan_liushui_value);
        mTxtXingyuanzhuanpanLiushui = (TextView) findViewById(R.id.txt_xingyuanzhuanpan_liushui);
        mTxtXinyunzhuanpanShuyingValue = (TextView) findViewById(R.id.txt_xinyunzhuanpan_shuying_value);
        mTxtShuiguoji = (TextView) findViewById(R.id.txt_shuiguoji);
        mView22 = (View) findViewById(R.id.view22);
        mTxtShuiguojiLiushuiValue = (TextView) findViewById(R.id.txt_shuiguoji_liushui_value);
        mTxtShuiguojiShuyingValue = (TextView) findViewById(R.id.txt_shuiguoji_shuying_value);
    }
}
